linux qt 配置路径,讲解在Linux下配置QT 学习之路 |
您所在的位置:网站首页 › linux qt库默认路径 › linux qt 配置路径,讲解在Linux下配置QT 学习之路 |
本文介绍的是讲解在Linux下配置QT 学习之路,我们首先来看内容。在CentOS下配置QT:通过yum search qt,得知源上可以安装的QT软件列表如下(有很多QT组件可以选择安装): qt.i386 : Qt GUI 工具包的共享库。 qt-MySQL.i386 : 用于 Qt 的 SQL 类别的 MySQL 驱动程序。 qt-ODBC.i386 : 用于 Qt 的 SQL 类别的 ODBC 驱动程序。 qt-PostgreSQL.i386 : 用于 Qt 的 SQL 类别的 PostgreSQL 驱动程序。 qt-config.i386 : 为使用 Qt 的程序提供的图形化配置工具。 qt-designer.i386 : Qt GUI 工具包的界面设计程序 (IDE) qt-devel.i386 : Development files for the Qt GUI toolkit. qt-devel-docs.i386 : Documentation for the Qt GUI toolkit. wpa_supplicant-gui.i386 : Graphical User Interface for wpa_supplicant PyQt.i386 : Qt 的 Python 绑定 PyQt-devel.i386 : 要建构基于 Qt 的其它绑定所需的文件 PyQt-examples.i386 : PyQt 的样例 avahi-qt3.i386 : Qt3 libraries for avahi // avahi是什么东西? avahi-qt3-devel.i386 : Libraries and header files for avahi Qt3 development pinentry-qt.i386 : Passphrase/PIN entry dialog based on Qt qt4.i386 : The shared library for the Qt GUI toolkit qt4-devel.i386 : Development files for the Qt GUI toolkit qt4-doc.i386 : API documentation, demos and example programs for qt4 qt4-mysql.i386 : MySQL drivers for Qt's SQL classes qt4-odbc.i386 : ODBC drivers for Qt's SQL classes qt4-postgresql.i386 : PostgreSQL drivers for Qt's SQL classes qt4-sqlite.i386 : SQLite drivers for Qt's SQL classes qtnx.i386 : QT4 based FreeNX Client scim-qtimm.i386 : Qt 的 SCIM 输入法模块 // 这个是SCIM模块,用Qt实现的吧? scribus.i386 : DeskTop Publishing application written in Qt sip.i386 : SIP - Python/C++ 绑定生成器. 通过rpm命令查询已经安装的Qt软件: [root@Tomato ~]# rpm -qa | grep qt qt-3.3.6-23.el5 scim-qtimm-0.9.4-5 avahi-qt3-0.6.16-6.el5 // Qt3和Qt4可以同时共存吗? Linux上编译居然因为环境变量,而报错: QMAKESPEC has not been set, so configuration cannot be deduced. Error processing project file: /root/qt/qt.pro 在脚本里加入该环境变量,这个错误已经消失: [root@localhost qt]# ls hello.cpp [root@localhost qt]# qmake -project [root@localhost qt]# ls hello.cpp qt.pro [root@localhost qt]# qmake [root@localhost qt]# ls hello.cpp Makefile qt.pro Make报如下错误: [root@localhost qt]# make g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/work/program/dsk/qt-everywhere-opensource-src-4.6.1/mkspecs/linux-g++ -I. -I/work/program/qtdevelop/include/QtCore -I/work/program/qtdevelop/include/QtGui -I/work/program/qtdevelop/include -I. -I. -o hello.o hello.cpp hello.cpp:1:24: 错误:QApplication:没有那个文件或目录 hello.cpp:2:18: 错误:QLabel:没有那个文件或目录 hello.cpp: In function ‘int main(int, char**)’: hello.cpp:6: 错误:‘QApplication’ 在此作用域中尚未声明 hello.cpp:6: 错误:expected `;' before ‘app’ hello.cpp:7: 错误:‘QLabel’ 在此作用域中尚未声明 hello.cpp:7: 错误:‘label’ 在此作用域中尚未声明 hello.cpp:7: 错误:expected type-specifier before ‘QLabel’ hello.cpp:7: 错误:expected `;' before ‘QLabel’ hello.cpp:9: 错误:‘app’ 在此作用域中尚未声明 hello.cpp: At global scope: hello.cpp:4: 警告:未使用的参数 ‘argc’ hello.cpp:4: 警告:未使用的参数 ‘argv’ make: *** [hello.o] 错误 1 生成的Makefile有些问题: CC=gcc CXX=g++ DEFINES= -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB CFLAGS= -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) CXXFLAGS= -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) INCPATH= -I/work/program/dsk/qt-everywhere-opensource-src-4.6.1/mkspecs/l inux-g++ -I. -I/work/program/qtdevelop/include/QtCore -I/work/program/qtdevelop/ include/QtGui -I/work/program/qtdevelop/include -I. -I. // 这个路径是怎么生成的?. LINK=g++ LFLAGS= -Wl,-O1 LIBS= $(SUBLIBS) -L/work/program/qtdevelop/lib -lQtGui -lQtCore -lpth read 简单文件运行出错: [root@localhost c++]# ./a.out -bash: ./a.out: cannot execute binary file // 刚开始出这个错是什么原因啊?重新编译后就正常了。。。 [root@localhost c++]# file a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped 修改Makefile之后,文件编译成功,但是运行仍然是报错的: [root@localhost qt]# make g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/work/program/dsk/qt-everywhere-opensource-src-4.6.1/mkspecs/linux-g++ -I. -I/work/program/dsk/qt-everywhere-opensource-src-4.6.1/include/QtCore -I/work/program/dsk/qt-everywhere-opensource-src-4.6.1/include/QtGui -I/work/program/dsk/qt-everywhere-opensource-src-4.6.1/include -I. -I. -o hello.o hello.cpp g++ -Wl,-O1 -o qt hello.o -L/work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib -lQtGui -lQtCore -lpthread [root@localhost qt]# ls hello.cpp hello.o Makefile qt qt.pro [root@localhost qt]# ./qt ./qt: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory 100216 缺少这个动态链接库,如何办?: 可以直接在路径里加上吗? [root@localhost qt]# find /work/program/dsk/qt-everywhere-opensource-src-4.6.1/ | grep libQtGui.so.4 /work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib/libQtGui.so.4.6.1 /work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib/libQtGui.so.4.6.1.debug /work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib/libQtGui.so.4.6 /work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib/libQtGui.so.4 ld文件配置: /etc/ld.so.conf include ld.so.conf.d/*.conf // 里面只有一行配置,表示去ld.so.conf.d目录中寻找配置信息。 /etc/ld.so.conf.d/qt-i386.conf 这里的配置信息为:usr/lib/qt-3.3/lib,指向老的qt配置。 /etc/ld.so.conf.d/mysql-i386.conf // 怎么只有两个ld配置文件? usr/lib/mysql 这个目录下还有很多配置文件: [root@localhost mkspecs]# pwd /work/program/dsk/qt-everywhere-opensource-src-4.6.1/mkspecs Qt库文件的实际位置: [root@localhost lib]# du -sh 425M . [root@localhost lib]# pwd /work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib. 设置完ld路径后,运行成功第一个Qt程序。。。: 现在的ld.so.conf.d下的qt配置内容如下: #/usr/lib/qt-3.3/lib // 之后需要运行ldconfig命令。 /work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib ld设置后,基于Qt的应用启动不了。。。: 把/usr/lib/qt-3.3/lib注释掉,只配置下面的选项(运行基于qt-3.3的应用程序出错,在界面是跳出报错窗口)。 /work/program/dsk/qt-everywhere-opensource-src-4.6.1/lib 在命令行报出的错误则有些不同: [root@localhost qt]# ksnapshot ksnapshot: error while loading shared libraries: libqt-mt.so.3: cannot open shared object file: No such file or directory 小结:关于讲解在Linux下配置QT学习之路的内容介绍完了希望本文对你有所帮助! 【编辑推荐】 【责任编辑:李程站 TEL:(010)68476606】 点赞 0 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |